package com.example.ByteStream;


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 缓冲流BufferedReader读取文件
 * @date 2023-12-13 13:53
 */
public class BufferedReaderDemo {
    public static void main(String[] args) throws IOException {
        //创建缓冲流
        FileReader fr = new FileReader("d:\\aaa.txt");
        BufferedReader br = new BufferedReader(fr);

        //读取
        //1.读取
//        char[] buf = new char[1024];
//        int count = 0;
//        while ((count = br.read(buf)) != -1) {
//            System.out.println(new String(buf, 0, count));
//        }
        //2.一行一行读取
        String line = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        //关闭
        br.close();
    }
}
